<?php
@session_start();
$_SESSION['uid'] = @$_REQUEST['uid'];
$for = $_SESSION['uid'];
if (!isset($_SESSION['u_id'])) {
	header("location:login.php");
}
?>
<html>
<head>
<title>Chat Window</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
		 <script type="text/javascript" src="js/jquery.form.js"></script> 
<script src="js/jquery-1.9.1.js"></script>
<script language="javascript" src="js/jquery.timers-1.0.0.js"></script>

<script>
	$(document).ready(function() {

		var j = jQuery.noConflict();
		j(document).ready(function() {
			j(".demo").everyTime(1000, function(i) {
				j.ajax({
					url : "refresh.php",
					cache : false,
					success : function(html) {
						j(".demo").html(html);
					}
				})
			})
		});
		j('.demo').css({
			color : "green"
		});
		document.getElementById('chatBox').scrollTop = 9999999;
		$(function() {
			$(".submit").click(function() {
				var msg = $("#message").val();

				var dataString = 'msg=' + msg;

				if (msg == '') {
					$('.success').fadeOut(200).hide();
					$('.error').fadeOut(200).show();
				} else {
					$.ajax({
						type : "POST",
						url : "join.php",
						data : dataString,
						success : function() {
							$("#form")[0].reset()
							$('.error').fadeOut(200).hide();
						}
					});
				}
				return false;
			});
		});
	}); 
</script>
</head>
<link rel="stylesheet" type="text/css" href="css/cb_style.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<style>
</style>
<body><table border="1px" align="center" width="55%"><tr><td>
<div id="chatBox" class="demo" align="center">

</div>
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("chat") or die(mysql_error());
?>

<div id="usersOnLine">
		<?php
		$sql = mysql_query("SELECT * FROM USERS") or die(mysql_error());
			?>
		<table width="100%">
			<tr>
				<th>All users</th></th>
				<?php while ($data=(mysql_fetch_assoc($sql))) { ?>
				<tr><td><a href="chatwindow.php?uid=<?=$data['u_id'] ?>"><?=$data['u_name'] ?></a></td><?php } ?>
			</tr>
		</table>
		
		<?php
		$grp = mysql_query("SELECT * FROM user_group") or die(mysql_error());
		?>
		<table width="100%">
			<tr>
				<th>All Group</th></th>
				<?php while ($data=(mysql_fetch_array($grp))) { ?>
				<tr><td><?=$data['g_name'] ?></td><?php } ?>
			</tr>
		</table>
	</div>




	<form method="post" action="" name="form" id="form">
		<input id="message" type="text" name="msg" autofocus="true">
		<input id="send" type="submit" value="submit" name="submit" class="submit">
		<a href="logout.php"> Logout</a>
</form>
</td></tr>
<script></script>
</body>
</html>
<?php
@session_start();

$u_name = $_SESSION['u_name'];
$u_email = $_SESSION['u_email'];
$u_id = $_SESSION['u_id'];
$group = $_SESSION['group'];
?> <tr><td>
 Hello <?=$u_name ?> Return to Your <a href="chatwindow.php">Group</a></td></tr></table>